/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import cn.webrx.ex.Ex1;

import javax.swing.*;
import java.io.Console;
import java.util.Scanner;

/**
 * <p>Project: javaseapp - Input1
 * <p>Powered by webrx On 2021-07-29 09:29:05
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Input1 {
    public static void main(String[] args) {
        Ex1.show();

        //1. java.util.Scanner
        //var sc = new Scanner(System.in);
        //System.out.print("请输入姓名：");
        //String name = sc.nextLine();
        //System.out.printf("%n欢迎你：%s。",name);

        //2. JOptionPane 输入内容确定就字符串值，只要不是确定都是null
        //String w = JOptionPane.showInputDialog("请输入词汇：");
        //String w = JOptionPane.showInputDialog("请输入词汇", "word");
        //String w = JOptionPane.showInputDialog(null, "请输入词汇", "超级词典",JOptionPane.QUESTION_MESSAGE);
        //System.out.println(w);

        //3. 安全输入
        //在控制台下,windows 控制台默认是GBK 936
        // chcp.com 65001 > NUL 设置控制台为utf8-8   也可以 chcp.com 936 > NUL 设置为GBK
        //设置为utf-8 java Input1.java 就没有乱码。
        Console con = System.console();
        String name = con.readLine("请输入姓名：");
        String password = new String(con.readPassword("请输入密码："));
        System.out.println(name);
        System.out.println(password);

    }
}
